package com.fr.report.js;

import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.ReportXMLUtils;
import com.fr.report.parameter.Parameter;

public abstract class AbstractJavaScript
  implements JavaScript
{
  protected Parameter[] parameters;

  public Parameter[] getParameters()
  {
    return ((this.parameters == null) ? new Parameter[0] : this.parameters);
  }

  public void setParameters(Parameter[] paramArrayOfParameter)
  {
    this.parameters = paramArrayOfParameter;
  }

  public boolean equals(Object paramObject)
  {
    if (this == paramObject)
      return true;
    if (!(paramObject instanceof AbstractJavaScript))
      return false;
    return ComparatorUtils.equals(this.parameters, ((AbstractJavaScript)paramObject).parameters);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("Parameters".equals(paramXMLableReader.getTagName())))
    {
      Parameter[] arrayOfParameter = ReportXMLUtils.readParameters(paramXMLableReader);
      setParameters(arrayOfParameter);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    ReportXMLUtils.writeParameters(paramXMLPrintWriter, getParameters());
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    int i;
    AbstractJavaScript localAbstractJavaScript = (AbstractJavaScript)super.clone();
    if (this.parameters != null)
    {
      localAbstractJavaScript.parameters = new Parameter[this.parameters.length];
      for (i = 0; i < this.parameters.length; ++i)
        localAbstractJavaScript.parameters[i] = ((Parameter)this.parameters[i].clone());
    }
    return localAbstractJavaScript;
  }
}